{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">情形</h3>

	<table class="layui-table">
		<tr>
			<td class="layui-td-gray">上级情形<font>*</font></td>
			<td>
				<select name="pid" lay-verify="required" lay-reqText="请选择上级情形">
					<option value="0">作为一级情形</option>
					{volist name="case_list" id="v"}
					<option value="{$v.id}" {notempty name="$detail.pid"}{eq name="$detail.pid" value="$v.id"} selected{/eq}{else/}{eq name="$pid" value="$v.id"} selected{/eq}{/notempty}>{$v.name}</option>
					{/volist}
				</select>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">情形描述<font>*</font></td>
			<td colspan="5">
				<textarea name="name" placeholder="请输入情形描述" lay-verify="required" class="layui-textarea">{notempty name="$detail.name"}{$detail.name}{/notempty}</textarea>
			</td>
		</tr>
	</table>
	<strong>审查要点</strong>
	<div id="points">
		{notempty name="$detail.points"}
		{volist name="$detail.points" id="val"}
		<table class="layui-table layui-table-min more_interfix">
			<tr>
				<input type="hidden" name="points_key" value="{$key+1}">
				<td class="layui-td-gray"><font>*</font>审查要点{$key+1}</td>
				<td colspan="5">
					<textarea name="points[content][]" placeholder="请输入审查要点" class="layui-textarea">{$val.content}</textarea>
					<input type="hidden" name="points[id][]" class="layui-input" value="{$val.id}">
				</td>
				<td><a class="layui-btn layui-btn-danger layui-btn-xs" data-id="{$val.id}" lay-event="del">删除</a></td>
			<tr>
		</table>
		{/volist}
		{else/}
		<table class="layui-table layui-table-min more_interfix">
			<tr>
				<input type="hidden" name="points_key" value="1">
				<td class="layui-td-gray"><font>*</font>审查要点1</td>
				<td colspan="5">
					<textarea name="points[content][]" placeholder="请输入审查要点" class="layui-textarea"></textarea>
					<input type="hidden" name="points[id][]" class="layui-input" value="0">
				</td>
				<td><a class="layui-btn layui-btn-danger layui-btn-xs" data-id="0" lay-event="del">删除</a></td>
			<tr>
		</table>
		{/notempty}
	</div>
	<div class="pt-2">
		<button class="layui-btn layui-btn-sm" type="button" id="add_points">+ 添加</button>
	</div>
	<hr>
	<strong>材料列表</strong>
	<div class="layui-collapse" id="material">
		{notempty name="$detail.material"}
		{volist name="$detail.material" id="val" key="keygen"}
		<div class="layui-colla-item more_interfix">
			<h2 class="layui-colla-title">
				{$val.name}
				<a class="layui-btn layui-btn-danger layui-btn-xs" style="margin-left: 10px;" data-id="{$val.id}" lay-event="del">删除材料</a>
			</h2>
			<div class="layui-colla-content">
				<table class="layui-table layui-table-min">
					<tr>
						<input type="hidden" name="material_key" value="{$keygen}">
						<td class="layui-td-gray"><font>*</font>材料名称</td>
						<td>
							<input type="text" name="material[name][{$keygen}]" value="{$val.name}" autocomplete="off" lay-verify="required" placeholder="请输入材料名称" lay-reqText="请输入材料名称" class="layui-input">
							<input type="hidden" name="material[id][{$keygen}]" class="layui-input" value="{$val.id}">
						</td>
						<td class="layui-td-gray"><font>*</font>免证办</td>
						<td>
							<input type="radio" name="material[exempt][{$keygen}]" value="1" title="是" {eq name="$val.exempt" value="1"}checked{/eq}>
							<input type="radio" name="material[exempt][{$keygen}]" value="2" title="否" {eq name="$val.exempt" value="2"}checked{/eq}>
						</td>
					<tr>
					<tr>
						<td class="layui-td-gray"><font>*</font>必要性</td>
						<td>
							<input type="radio" name="material[necessity][{$keygen}]" value="1" title="必须" {eq name="$val.necessity" value="1"}checked{/eq}>
							<input type="radio" name="material[necessity][{$keygen}]" value="2" title="非必须" {eq name="$val.necessity" value="2"}checked{/eq}>
							<input type="radio" name="material[necessity][{$keygen}]" value="3" title="信用免交、信用后补" {eq name="$val.necessity" value="3"}checked{/eq}>
							<input type="radio" name="material[necessity][{$keygen}]" value="3" title="容缺后补" {eq name="$val.necessity" value="3"}checked{/eq}>
						</td>
						<td class="layui-td-gray"><font>*</font>类型</td>
						<td>
							<input type="radio" name="material[type][{$keygen}]" value="1" title="原件" {eq name="$val.type" value="1"}checked{/eq}>
							<input type="radio" name="material[type][{$keygen}]" value="2" title="复印件" {eq name="$val.type" value="2"}checked{/eq}>
							<input type="radio" name="material[type][{$keygen}]" value="3" title="原件和复印件" {eq name="$val.type" value="3"}checked{/eq}>
							<input type="radio" name="material[type][{$keygen}]" value="4" title="电子版" {eq name="$val.type" value="4"}checked{/eq}>
						</td>
					</tr>
					<tr>
						<td class="layui-td-gray"><font>*</font>形式</td>
						<td>
							<input type="radio" name="material[shape][{$keygen}]" value="1" title="纸质" {eq name="$val.shape" value="1"}checked{/eq}>
							<input type="radio" name="material[shape][{$keygen}]" value="2" title="电子" {eq name="$val.shape" value="2"}checked{/eq}>
							<input type="radio" name="material[shape][{$keygen}]" value="3" title="纸质和电子" {eq name="$val.shape" value="3"}checked{/eq}>
							<input type="radio" name="material[shape][{$keygen}]" value="4" title="纸质或电子" {eq name="$val.shape" value="4"}checked{/eq}>
						</td>
						<td class="layui-td-gray">纸质材料份数</td>
						<td>
							<input type="number" name="material[number][{$keygen}]" value="{$val.number}" autocomplete="off" placeholder="请输入" lay-reqText="请输入" class="layui-input">
						</td>
					</tr>
					<tr>
						<td class="layui-td-gray"><font>*</font>来源</td>
						<td>
							<input type="radio" name="material[source][{$keygen}]" value="1" title="申请人自备" {eq name="$val.source" value="1"}checked{/eq}>
							<input type="radio" name="material[source][{$keygen}]" value="2" title="政府部门核发" {eq name="$val.source" value="2"}checked{/eq}>
							<input type="radio" name="material[source][{$keygen}]" value="3" title="其它" {eq name="$val.source" value="3"}checked{/eq}>
						</td>
						<td class="layui-td-gray">核发部门</td>
						<td>
							<input type="text" name="material[source_info][{$keygen}]" value="{$val.source_info}" autocomplete="off" placeholder="请输入" lay-reqText="请输入" class="layui-input">
						</td>
					</tr>
					<tr>
						<td class="layui-td-gray">填报须知</td>
						<td>
							<textarea name="material[notice][{$keygen}]" placeholder="请输入" class="layui-textarea">{$val.notice}</textarea>
						</td>
						<td class="layui-td-gray">受理标准</td>
						<td>
							<textarea name="material[standard][{$keygen}]" placeholder="请输入" class="layui-textarea">{$val.standard}</textarea>
						</td>
					</tr>
					<tr>
						<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn{$keygen}_1"><i class="layui-icon"></i>样表</button></td>
						<td colspan="5" style="line-height:inherit">
							<div class="layui-row" id="fileBox{$keygen}_1">
								<input type="hidden" id="fileBox{$keygen}_1Input" name="material[sample_table][{$keygen}]" value="{$val.sample_table}">
								{notempty name="$val.sample_table"}
								{volist name="$val.sample_tableArray" id="vo"}
								<div class="layui-col-md4" id="fileItem{$vo.id}">
									<div class="file-card">
										<i class="file-icon iconfont icon-renwuguanli"></i>
										<div class="file-title">{$vo.name}</div>
										<div class="file-tool">
											<a href="{$vo.filepath}" download="{$vo.name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
											<i class="btn-delete iconfont icon-shanchu red" data-id="{$vo.id}" title="删除" style="font-size: 14px;">删除</i>
										</div>
									</div>
								</div>
								{/volist}
								{/notempty}
							</div>
						</td>
					</tr>
					<tr>
						<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn{$keygen}_2"><i class="layui-icon"></i>空表</button></td>
						<td colspan="5" style="line-height:inherit">
							<div class="layui-row" id="fileBox{$keygen}_2">
								<input type="hidden" id="fileBox{$keygen}_2Input" name="material[empty_table][{$keygen}]" value="{$val.empty_table}">
								{notempty name="$val.empty_table"}
								{volist name="$val.empty_tableArray" id="vo"}
								<div class="layui-col-md4" id="fileItem{$vo.id}">
									<div class="file-card">
										<i class="file-icon iconfont icon-renwuguanli"></i>
										<div class="file-title">{$vo.name}</div>
										<div class="file-tool">
											<a href="{$vo.filepath}" download="{$vo.name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
											<i class="btn-delete iconfont icon-shanchu red" data-id="{$vo.id}" title="删除" style="font-size: 14px;">删除</i>
										</div>
									</div>
								</div>
								{/volist}
								{/notempty}
							</div>
						</td>
					</tr>
					<tr>
						<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn{$keygen}_3"><i class="layui-icon"></i>材料模板</button></td>
						<td colspan="5" style="line-height:inherit">
							<div class="layui-row" id="fileBox{$keygen}_3">
								<input type="hidden" id="fileBox{$keygen}_3Input" name="material[template][{$keygen}]" value="{$val.template}">
								{notempty name="$val.template"}
								{volist name="$val.templateArray" id="vo"}
								<div class="layui-col-md4" id="fileItem{$vo.id}">
									<div class="file-card">
										<i class="file-icon iconfont icon-renwuguanli"></i>
										<div class="file-title">{$vo.name}</div>
										<div class="file-tool">
											<a href="{$vo.filepath}" download="{$vo.name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
											<i class="btn-delete iconfont icon-shanchu red" data-id="{$vo.id}" title="删除" style="font-size: 14px;">删除</i>
										</div>
									</div>
								</div>
								{/volist}
								{/notempty}
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		{/volist}
		{/notempty}
	</div>
	<div class="pt-2">
		<button class="layui-btn layui-btn-sm add_material" type="button" material-type="1">+ 材料</button>
		<button class="layui-btn layui-btn-sm add_material" type="button" material-type="2">+ 通用材料</button>
	</div>
	<div class="py-3">
		<input type="hidden" name="id" value="{$id}">
		<input type="hidden" name="matter_id" value="{$matter_id}">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>

</form>
<div id="material_select" style="display:none;">

	{volist name="$general_material" id="vo"}
	<option value="{$vo.id}">{$vo.name}</option>
	{/volist}
</div>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','oaTool'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,element=layui.element,oaTool = layui.oaTool;
		//监听提交
		form.on('submit(webform)', function(data){
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					setTimeout(function () {
						parent.location.reload();
					}, 1000);					
				}
			}
			tool.post("/matter/matter_case/add", data.field, callback);
			return false;
		});

		//审查要点
		$('#add_points').on('click',function(){
			let sort = Number($('[name="points_key"]').last().val());
			sort = sort?sort+1:1;
			var html = '';
			html += `<table class="layui-table layui-table-min more_interfix">
						<tr>
							<input type="hidden" name="points_key" value="${sort}">
                            <td class="layui-td-gray"><font>*</font>审查要点${sort}</td>
                            <td colspan="5">
								<textarea name="points[content][]" placeholder="请输入审查要点" class="layui-textarea"></textarea>
								<input type="hidden" name="points[id][]" class="layui-input" value="0">
							</td>
							<td><a class="layui-btn layui-btn-danger layui-btn-xs" data-id="0" lay-event="del">删除</a></td>
                        <tr>
                      </table>`;
			$("#points").append(html).find('.tr-none').remove();
			sort++;
			form.render();
		});
		$('#points').on('click', '[lay-event="del"]', function() {
			var that=$(this);
			var _id = that.data('id');
			if(_id>0){
				layer.confirm('确定删除该数据项？', {
					icon: 3,
					title: '提示'
				}, function(index) {
					$.ajax({
						url: "/matter/matter/points_delete",
						type:'post',
						data: {id: _id},
						success: function(res) {
							layer.msg(res.msg);
							if (res.code == 0) {
								that.parents(".more_interfix").remove();
							}
						}
					})
					layer.close(index);
				});
			}
			else{
				that.parents(".more_interfix").remove();
			}
		});



		$.each($('#material .more_interfix'),function(index, value) {
			let id = index+1;
			oaTool.addFile({btn:`uploadBtn${id}_1`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${id}_1`});
			oaTool.addFile({btn:`uploadBtn${id}_2`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${id}_2`});
			oaTool.addFile({btn:`uploadBtn${id}_3`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${id}_3`});
		})
		//材料列表
		$('.add_material').on('click',function(){
			let sort = Number($('[name="material_key"]').last().val());
			sort = sort?sort+1:1;
			var html = '';
			let type = $(this).attr('material-type');
			if(type==1){
				html += `<div class="layui-colla-item more_interfix">
				<h2 class="layui-colla-title">
					材料${sort}
					<a class="layui-btn layui-btn-danger layui-btn-xs" style="margin-left: 10px;" data-id="0" lay-event="del">删除材料</a>
				</h2>
				<div class="layui-colla-content layui-show">
					<table class="layui-table layui-table-min">
						<tr>
							<input type="hidden" name="material_key" value="${sort}">
							<td class="layui-td-gray"><font>*</font>材料名称</td>
							<td>
								<input type="text" name="material[name][${sort}]" value="" autocomplete="off" lay-verify="required" placeholder="请输入材料名称" lay-reqText="请输入材料名称" class="layui-input">
								<input type="hidden" name="material[id][${sort}]" class="layui-input" value="0">
							</td>
							<td class="layui-td-gray"><font>*</font>免证办</td>
							<td>
								<input type="radio" name="material[exempt][${sort}]" value="1" title="是">
								<input type="radio" name="material[exempt][${sort}]" value="2" title="否" checked>
							</td>
						<tr>
						<tr>
							<td class="layui-td-gray"><font>*</font>必要性</td>
							<td>
								<input type="radio" name="material[necessity][${sort}]" value="1" title="必须" checked>
								<input type="radio" name="material[necessity][${sort}]" value="2" title="非必须">
								<input type="radio" name="material[necessity][${sort}]" value="3" title="信用免交、信用后补">
								<input type="radio" name="material[necessity][${sort}]" value="4" title="容缺后补">
							</td>
							<td class="layui-td-gray"><font>*</font>类型</td>
							<td>
								<input type="radio" name="material[type][${sort}]" value="1" title="原件" checked>
								<input type="radio" name="material[type][${sort}]" value="2" title="复印件">
								<input type="radio" name="material[type][${sort}]" value="3" title="原件和复印件">
								<input type="radio" name="material[type][${sort}]" value="4" title="电子版">
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><font>*</font>形式</td>
							<td>
								<input type="radio" name="material[shape][${sort}]" value="1" title="纸质" checked>
								<input type="radio" name="material[shape][${sort}]" value="2" title="电子">
								<input type="radio" name="material[shape][${sort}]" value="3" title="纸质和电子">
								<input type="radio" name="material[shape][${sort}]" value="4" title="纸质或电子">

							</td>
							<td class="layui-td-gray">纸质材料份数</td>
							<td>
								<input type="number" name="material[number][${sort}]" value="" autocomplete="off" placeholder="请输入" lay-reqText="请输入" class="layui-input">
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><font>*</font>来源</td>
							<td>
								<input type="radio" name="material[source][${sort}]" value="1" title="申请人自备" checked>
								<input type="radio" name="material[source][${sort}]" value="2" title="政府部门核发">
								<input type="radio" name="material[source][${sort}]" value="3" title="其它">
							</td>
							<td class="layui-td-gray">核发部门</td>
							<td>
								<input type="text" name="material[source_info][${sort}]" value="" autocomplete="off" placeholder="请输入" lay-reqText="请输入" class="layui-input">
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray">填报须知</td>
							<td>
								<textarea name="material[notice][${sort}]" placeholder="请输入" class="layui-textarea"></textarea>
							</td>
							<td class="layui-td-gray">受理标准</td>
							<td>
								<textarea name="material[standard][${sort}]" placeholder="请输入" class="layui-textarea"></textarea>
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn${sort}_1"><i class="layui-icon"></i>样表</button></td>
							<td colspan="5" style="line-height:inherit">
								<div class="layui-row" id="fileBox${sort}_1">
									<input type="hidden" id="fileBox${sort}_1Input" name="material[sample_table][${sort}]" value="">
								</div>
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn${sort}_2"><i class="layui-icon"></i>空表</button></td>
							<td colspan="5" style="line-height:inherit">
								<div class="layui-row" id="fileBox${sort}_2">
									<input type="hidden" id="fileBox${sort}_2Input" name="material[empty_table][${sort}]" value="">
								</div>
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn${sort}_3"><i class="layui-icon"></i>材料模板</button></td>
							<td colspan="5" style="line-height:inherit">
								<div class="layui-row" id="fileBox${sort}_3">
									<input type="hidden" id="fileBox${sort}_3Input" name="material[template][${sort}]" value="">
								</div>
							</td>
						</tr>
					</table>
				</div>
			</div>`;

				$("#material").append(html).find('.tr-none').remove();
				oaTool.addFile({btn:`uploadBtn${sort}_1`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${sort}_1`});
				oaTool.addFile({btn:`uploadBtn${sort}_2`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${sort}_2`});
				oaTool.addFile({btn:`uploadBtn${sort}_3`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${sort}_3`});
				form.render();
				element.render();
			}else{
				//通用材料
				let material_select = $('#material_select').html();

				html += `<div class="layui-colla-item more_interfix">
				<h2 class="layui-colla-title">
					材料${sort}（通用）
					<a class="layui-btn layui-btn-danger layui-btn-xs" style="margin-left: 10px;" data-id="0" lay-event="del">删除材料</a>
				</h2>
				<div class="layui-colla-content layui-show">
					<table class="layui-table layui-table-min">
						<tr>
							<input type="hidden" name="material_key" value="${sort}">
							<td class="layui-td-gray"><font>*</font>材料名称</td>
							<td>
								<input type="hidden" name="material[name][${sort}]" class="layui-input" value="">
								<select name="material[name_id][${sort}]" lay-filter="material_name" lay-verify="required" lay-reqText="请选择材料名称">${material_select}</select>
								<input type="hidden" name="material[id][${sort}]" class="layui-input" value="0">
							</td>
							<td class="layui-td-gray"><font>*</font>免证办</td>
							<td>
								<input type="radio" name="material[exempt][${sort}]" value="1" title="是">
								<input type="radio" name="material[exempt][${sort}]" value="2" title="否" checked>
							</td>
						<tr>
						<tr>
							<td class="layui-td-gray"><font>*</font>必要性</td>
							<td>
								<input type="radio" name="material[necessity][${sort}]" value="1" title="必须" checked>
								<input type="radio" name="material[necessity][${sort}]" value="2" title="非必须">
								<input type="radio" name="material[necessity][${sort}]" value="3" title="信用免交、信用后补">
								<input type="radio" name="material[necessity][${sort}]" value="4" title="容缺后补">
							</td>
							<td class="layui-td-gray"><font>*</font>类型</td>
							<td>
								<input type="radio" name="material[type][${sort}]" value="1" title="原件" checked>
								<input type="radio" name="material[type][${sort}]" value="2" title="复印件">
								<input type="radio" name="material[type][${sort}]" value="3" title="原件和复印件">
								<input type="radio" name="material[type][${sort}]" value="4" title="电子版">
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><font>*</font>形式</td>
							<td>
								<input type="radio" name="material[shape][${sort}]" value="1" title="纸质" checked>
								<input type="radio" name="material[shape][${sort}]" value="2" title="电子">
								<input type="radio" name="material[shape][${sort}]" value="3" title="纸质和电子">
								<input type="radio" name="material[shape][${sort}]" value="4" title="纸质或电子">

							</td>
							<td class="layui-td-gray">纸质材料份数</td>
							<td>
								<input type="number" name="material[number][${sort}]" value="" autocomplete="off" placeholder="请输入" lay-reqText="请输入" class="layui-input">
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><font>*</font>来源</td>
							<td>
								<input type="radio" name="material[source][${sort}]" value="1" title="申请人自备" checked>
								<input type="radio" name="material[source][${sort}]" value="2" title="政府部门核发">
								<input type="radio" name="material[source][${sort}]" value="3" title="其它">
							</td>
							<td class="layui-td-gray">核发部门</td>
							<td>
								<input type="text" name="material[source_info][${sort}]" value="" autocomplete="off" placeholder="请输入" lay-reqText="请输入" class="layui-input">
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray">填报须知</td>
							<td>
								<textarea name="material[notice][${sort}]" placeholder="请输入" class="layui-textarea"></textarea>
							</td>
							<td class="layui-td-gray">受理标准</td>
							<td>
								<textarea name="material[standard][${sort}]" placeholder="请输入" class="layui-textarea"></textarea>
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn${sort}_1"><i class="layui-icon"></i>样表</button></td>
							<td colspan="5" style="line-height:inherit">
								<div class="layui-row" id="fileBox${sort}_1">
									<input type="hidden" id="fileBox${sort}_1Input" name="material[sample_table][${sort}]" value="">
								</div>
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn${sort}_2"><i class="layui-icon"></i>空表</button></td>
							<td colspan="5" style="line-height:inherit">
								<div class="layui-row" id="fileBox${sort}_2">
									<input type="hidden" id="fileBox${sort}_2Input" name="material[empty_table][${sort}]" value="">
								</div>
							</td>
						</tr>
						<tr>
							<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn${sort}_3"><i class="layui-icon"></i>材料模板</button></td>
							<td colspan="5" style="line-height:inherit">
								<div class="layui-row" id="fileBox${sort}_3">
									<input type="hidden" id="fileBox${sort}_3Input" name="material[template][${sort}]" value="">
								</div>
							</td>
						</tr>
					</table>
				</div>
			</div>`;

				$("#material").append(html).find('.tr-none').remove();
				oaTool.addFile({btn:`uploadBtn${sort}_1`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${sort}_1`});
				oaTool.addFile({btn:`uploadBtn${sort}_2`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${sort}_2`});
				oaTool.addFile({btn:`uploadBtn${sort}_3`,exts:'png|jpg|gif|jpeg|doc|docx|xls|xlsx|pdf',box: `fileBox${sort}_3`});
				form.render();
				element.render();
				general_material(sort,0);
			}


			sort++;
			$("html, body").animate({ scrollTop: $(document).height() }, 700);
		});
		$('#material').on('click', '[lay-event="del"]', function() {
			var that=$(this);
			var _id = that.data('id');
			if(_id>0){
				layer.confirm('确定删除该数据项？', {
					icon: 3,
					title: '提示'
				}, function(index) {
					$.ajax({
						url: "/matter/matter_case/material_delete",
						type:'post',
						data: {id: _id},
						success: function(res) {
							layer.msg(res.msg);
							if (res.code == 0) {
								that.parents(".more_interfix").remove();
							}
						}
					})
					layer.close(index);
				});
			}
			else{
				that.parents(".more_interfix").remove();
			}
		});

		//通用材料选择
		form.on('select(material_name)', function(data){
			let material_key = $(this).parents('tr').children('[name="material_key"]').val();
			general_material(material_key,data.value)


		});

		function general_material(material_key,general_material_id)
		{
			$.ajax({
				type:"get",
				url:"/matter/general_material/info?id="+general_material_id,
				dataType:"json",
				success:function (d) {
					$(`[name="material[name][${material_key}]"]`).val(d.name);
					let file1 = `<input type="hidden" id="fileBox${material_key}_1Input" name="material[sample_table][${material_key}]" value="${d.sample_table}">`;
					let file2 = `<input type="hidden" id="fileBox${material_key}_2Input" name="material[empty_table][${material_key}]" value="${d.empty_table}">`;
					let file3 = `<input type="hidden" id="fileBox${material_key}_3Input" name="material[template][${material_key}]" value="${d.template}">`;
					if(d.sample_table){
						for (let i = 0;i < d.sample_tableArray.length;i++){
							file1 +=`<div class="layui-col-md4" id="fileItem${d.sample_tableArray[i].id}">
									<div class="file-card">
									<i class="file-icon iconfont icon-renwuguanli"></i>
									<div class="file-title">${d.sample_tableArray[i].name}</div>
									<div class="file-tool">
									<a href="${d.sample_tableArray[i].filepath}" download="${d.sample_tableArray[i].name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
									<i class="btn-delete iconfont icon-shanchu red" data-id="${d.sample_tableArray[i].id}" title="删除" style="font-size: 14px;">删除</i>
									</div>
									</div>
								</div>`;
						}
						$(`#fileBox${material_key}_1`).html(file1);
					}else{
						$(`#fileBox${material_key}_1`).html(file1);
					}
					if(d.empty_table){
						for (let i = 0;i < d.empty_tableArray.length;i++){
							file2 +=`<div class="layui-col-md4" id="fileItem${d.empty_tableArray[i].id}">
									<div class="file-card">
									<i class="file-icon iconfont icon-renwuguanli"></i>
									<div class="file-title">${d.empty_tableArray[i].name}</div>
									<div class="file-tool">
									<a href="${d.empty_tableArray[i].filepath}" download="${d.empty_tableArray[i].name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
									<i class="btn-delete iconfont icon-shanchu red" data-id="${d.empty_tableArray[i].id}" title="删除" style="font-size: 14px;">删除</i>
									</div>
									</div>
								</div>`;
						}
						$(`#fileBox${material_key}_2`).html(file2);
					}else{
						$(`#fileBox${material_key}_2`).html(file2);
					}
					if(d.template){
						for (let i = 0;i < d.templateArray.length;i++){
							file3 +=`<div class="layui-col-md4" id="fileItem${d.templateArray[i].id}">
									<div class="file-card">
									<i class="file-icon iconfont icon-renwuguanli"></i>
									<div class="file-title">${d.templateArray[i].name}</div>
									<div class="file-tool">
									<a href="${d.templateArray[i].filepath}" download="${d.templateArray[i].name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
									<i class="btn-delete iconfont icon-shanchu red" data-id="${d.templateArray[i].id}" title="删除" style="font-size: 14px;">删除</i>
									</div>
									</div>
								</div>`;
						}
						$(`#fileBox${material_key}_3`).html(file3);
					}else{
						$(`#fileBox${material_key}_3`).html(file3);
					}

				},error:function () {
					layer.alert('请求失败');
				}
			});

		}
	}
</script>
{/block}
<!-- /脚本 -->
